<template>
    <div>
        <el-form :model="editForm" label-position="right"  ref="editFormRef" label-width="80px">
            <el-row>
                <el-col :span="10">
                    <div class="grid-content bg-purple">
                        <el-form-item label="用户名" prop="username">
                            <el-input v-model="editForm.username"></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="10">
                    <el-form-item label="联系方式" prop="phoneNumber">
                        <el-input v-model="editForm.phoneNumber"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="10">
                    <div class="grid-content bg-purple">
                        <el-form-item label="昵称" prop="nickname">
                            <el-input v-model="editForm.nickname"></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="12">
                    <div class="grid-content bg-purple-light">
                        <el-form-item label="性别" prop="sex">
                            <el-radio-group v-model="editForm.sex">
                                <el-radio :label="0">男</el-radio>
                                <el-radio :label="1">女</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
        </el-form>
        <el-row style="text-align: center;">
            <el-button type="primary" @click="add()">确 定</el-button>
            <el-button @click="closed()">取 消</el-button>
        </el-row>
    </div>
</template>
<script>
    import userApi from "@/api/user"
    import store from "@/store"
    import { Message } from 'element-ui'
    export default {
        data () {
            return{
                editForm:{
                    password:""
                }
            }
        },
        created(){},
        methods:{
            closed(){
                this.$emit('closeDialog')
            },
            add(){
                userApi.addUser(this.editForm).then(res =>{
                    Message.success(res.message)
                    this.$emit('getUserList')
                    this.closed()
                    this.editForm = {password:""}
                })
            }

        }

    }
</script>
